package leetcode.editor.day;

import java.util.*;

// 1408. 数组中的字符串匹配
// https://leetcode.cn/problems/string-matching-in-an-array/
class StringMatchingInAnArray {
    public static void main(String[] args) {
        Solution solution = new StringMatchingInAnArray().new Solution();
        solution.stringMatching(new String[]{"leetcode", "leet", "code"});
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public List<String> stringMatching(String[] words) {
            Set<String> res = new HashSet<>();

            for (int i = 0; i < words.length; i++) {
                for (int j = 0; j < words.length; j++) {
                    if (i != j && words[i].contains(words[j])) {
                        res.add(words[j]);
                    }
                }
            }

            return new ArrayList<>(res);
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}
